/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2302 - ArrSort3
 * <p>Powered by webrx On 2023-06-14 11:41:27
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ArrSort3 {
    public static void main(String[] args) {
        String[] ns = {"张三", "李四", "王五", "赵六", "张三丰"};
        System.out.println(Arrays.toString(ns));

        //洗牌
        Arrays.sort(ns, (a, b) -> Math.random() > .5 ? -1 : 1);
        System.out.println(Arrays.toString(ns));

        //升序
        Arrays.sort(ns);
        Arrays.sort(ns, (a, b) -> a.compareTo(b));
        System.out.println(Arrays.toString(ns));

        //降序
        Arrays.sort(ns, (a, b) -> b.compareTo(a));
        System.out.println(Arrays.toString(ns));

        //System.out.println((int)'张');
        //System.out.println((int)'李');
        //System.out.println((int)'王');
        //System.out.println((int)'男');
        //System.out.println((int)'女');
        //System.out.println((int)'a');
        //System.out.println((int)'A');


        //按字符个数
        String[] ls = {"javascript", "rust", "go", "python", "java", "c"};
        //Arrays.sort(ls,(a,b)->a.length()-b.length());
        Arrays.sort(ls,(a,b)->b.length()-a.length());
        System.out.println(Arrays.toString(ls));
    }
}
